﻿/*******************************************************************************
 **  Name:                                        **
 **  Description:                                                             **
 **                                                                           **
 **  CDDL: Open Source Initiative (OSI) Approved License                            **
 **                                                                           **
 **  Copyright (c) 2009-2010 Barry "Gian" James  <bjames@munixos.net>         **
 **  All rights reserved.                                                     **
 **                                                                           **
 **  The contents of this file are subject to the terms of the CDDL:          **
 **  Common Development and Distribution License (the "License").             **
 **  You may not use this file except in compliance with the License.         **
 **                                                                           **
 **  You can obtain a copy of the license at $PROJECT_ROOT/LICENSE            **
 **  or http://www.opensolaris.org/os/licensing.  This code is Open Source    **
 **  and you are free to use it within the confines of the license, even      **
 **  for your own closed-source commercial projects, as long as you follow    **
 **  the terms set forth in the CDDL.                                         **
 **                                                                           **
 **  When distributing Covered Code, include this CDDL HEADER in each         **
 **  file and include the License file at $PROJECT_ROOT/LICENSE.              **
 **  If applicable, add the following below this CDDL HEADER, with the        **
 **  fields enclosed by brackets "[]" replaced with your own identifying      **
 **  information: Portions Copyright [yyyy] [name of copyright owner]         **
 **                                                                           **
 ******************************************************************************/
// Created on November 1, 2010, 7:25 AM
// Modified $Date$ by $Author$
// $Id$

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace sat1baf1
{
    public partial class AgentInfoForm : Form
    {
        private bool _isNewAgent = false;

        public AgentInfoForm()
        {
            InitializeComponent();
        }

        public bool IsNewAgent
        {
            get { return _isNewAgent; }
            set
            {
                _isNewAgent = value;
                if (!value)
                {
                    btnCommit.Enabled = false;
                }
            }
        }

        private int AttributeMod(int attr)
        {
            switch(attr)
            {
                case 1:
                    return -5;
                case 2:
                case 3:
                    return -4;
                case 4:
                case 5:
                    return -3;
                case 6:
                case 7:
                    return -2;
                case 8:                
                case 9:
                    return -1;
                case 10:
                case 11:
                    return 0;
                case 12:
                case 13:
                    return 1;
                case 14:
                case 15:
                    return 2;
                case 16:
                case 17:
                    return 3;
                case 18:
                case 19:
                    return 4;
                case 20:
                case 21:
                    return 5;
                case 22:
                case 23:
                    return 6;
                case 24:
                case 25:
                    return 7;
                case 26:
                case 27:
                    return 8;
                case 28:
                case 29:
                    return 9;
                case 30:
                case 31:
                    return 10;
                case 32:
                case 33:
                    return 11;
            }
            return -1;
        }

        private void txtAttrSTR_TextChanged(object sender, EventArgs e)
        {
            int mod = AttributeMod(System.Convert.ToInt16(txtAttrSTR.Text));
            string str = mod.ToString();
            txtSTRMod.Text = str;
            txtUnarmedAttrBonus.Text = str;
            txtMeleeAttrMod.Text = str;
            txtUnarmedAttrBonus.Text = str;
            txtMeleeAttrMod.Text = str;
        }

        private void txtDEXChanged(object sender, EventArgs e)
        {
            int num = System.Convert.ToInt16(txtAttrDEX.Text);
            int mod = AttributeMod(num);
            string str = num.ToString();
            txtDEXMod.Text = str;
            txtInitiativeDEXBonus.Text = str;
            txtRangedAttrMod.Text = str;
            txtRangedAttrMod.Text = str;
            txtReflexAttrBonus.Text = str;
        }

        private void txtCONChanged(object sender, EventArgs e)
        {
            int mod = AttributeMod(System.Convert.ToInt16(txtAttrCON.Text));
            txtCONMod.Text = mod.ToString();
            txtSubdualMax.Text = mod.ToString();
            txtSubdualCurr.Text = mod.ToString();
            txtWoundsCurr.Text = mod.ToString();
            txtWoundsMax.Text = mod.ToString();
 //           txtFortitudeAttrBonus
        }

        private void txtINTChanged(object sender, EventArgs e)
        {
            int mod = AttributeMod(System.Convert.ToInt16(txtAttrINT.Text));
            txtINTMod.Text = mod.ToString();
            txtKnowledgeCheckAttrMod.Text = txtINTMod.Text;
        }

        private void txtWISChanged(object sender, EventArgs e)
        {
            int mod = AttributeMod(System.Convert.ToInt16(txtAttrWIS.Text));
            txtWISMod.Text = mod.ToString();
            txtStressMax.Text = txtAttrWIS.Text;
            txtStressCurr.Text = txtAttrWIS.Text;
            txtWillAttrBonus.Text = txtWISMod.Text;
        }

        private void txtCHAChanged(object sender, EventArgs e)
        {
            int mod = AttributeMod(System.Convert.ToInt16(txtAttrCHA.Text));
            txtCHAMod.Text = mod.ToString();
            txtRequestCheckAttrMod.Text = txtCHAMod.Text;
        }




    } // class AgentInfoForm
}
